package net.telesing.tcmc.back.service.impl;

import java.io.File;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import net.telesing.tcmc.back.logic.ApiLogic;
import net.telesing.tcmc.back.service.ApiService;
import net.telesing.tcmc.common.Constants;

/**
 * api接口实现
 * 
 * Created by Zmt on 2015/12/2.
 */
@IocBean
public class ApiServiceImpl implements ApiService
{
    @Inject
    private ApiLogic apiLogic;

    @Override
    public File downloadApk(HttpServletResponse response)
    {
        return apiLogic.download(response, Constants.ACS_APK_URL, "queyintong.apk");
    }

    @Override
    public Map<String, Object> checkUpdate(int code)
    {
        return apiLogic.checkUpdate(code);
    }

    @Override
    public Map<String, Object> getSectionById(long id)
    {
        return apiLogic.getSection(id, null, 1);
    }

    @Override
    public Map<String, Object> getSectionBySecret(String secret)
    {
        return apiLogic.getSection(0, secret, 2);
    }

    @Override
    public Map<String, Object> getSection(String userName, String pwd)
    {
        return apiLogic.getSection(userName, pwd);
    }

    @Override
    public Map<String, Object> getCertificate(String userName, String pwd, String sName, int cType, HttpServletRequest httpServletRequest)
    {
        return apiLogic.getCertificate(userName, pwd, sName, cType, httpServletRequest);
    }

    @Override
    public Map<String, Object> getSectionByName(String section)
    {
        return apiLogic.getSection(section);
    }

}
